import request from '@/axios';

export const getList = (current, size, params) => request({
  url: '/zzy-system/role/list',
  method: 'get',
  params: {
    ...params,
    current,
    size,
  },
});
export const grantTree = () => request({
  url: '/zzy-system/menu/grant-tree',
  method: 'get',
});

export const grant = (roleIds, menuIds, dataScopeIds, apiScopeIds) => request({
  url: '/zzy-system/role/grant',
  method: 'post',
  data: {
    roleIds,
    menuIds,
    dataScopeIds,
    apiScopeIds,
  },
});

export const remove = ids => request({
  url: '/zzy-system/role/remove',
  method: 'post',
  params: {
    ids,
  },
});

export const add = row => request({
  url: '/zzy-system/role/submit',
  method: 'post',
  data: row,
});

export const update = row => request({
  url: '/zzy-system/role/submit',
  method: 'post',
  data: row,
});

export const getRole = roleIds => request({
  url: '/zzy-system/menu/role-tree-keys',
  method: 'get',
  params: {
    roleIds,
  },
});

export const getRoleTree = tenantId => request({
  url: '/zzy-system/role/tree',
  method: 'get',
  params: {
    tenantId,
  },
});

export const getRoleTreeById = roleId => request({
  url: '/zzy-system/role/tree-by-id',
  method: 'get',
  params: {
    roleId,
  },
});
